package com.njupt.Array;

public class IsPerfectSquare {

    public boolean isPerfectSquare(int num) {
        for (int i = 1; i <=num ; i++) {
            if((long)(i * i) >num){
                break;
            }

            if((long)(i * i) == num){
                return true;
            }
        }
        return false;
    }

    public boolean isPerfectSquare1(int num) {
        long result = 1,x =1;
        while(result <= num){
            if(result == num){
                return true;
            }
            ++x;
            result = x * x;
        }
        return false;
    }

    public static void main(String[] args) {
        int num = 14;
        IsPerfectSquare test = new IsPerfectSquare();
        System.out.println(test.isPerfectSquare1(num));
    }
}
